package com.horsecoder.im.common.protocol.context.identity;

import java.net.SocketAddress;
import java.util.Objects;

/**
 * Author: Zhu yuhan
 * Email: zhuyuhan2333@qq.com
 * Date: 2022/3/17 10:52 上午
 **/
public class ChannelIdentity {

    private SocketAddress socketAddress;

    private String channelId;

    private String userIdentity;

    public ChannelIdentity(SocketAddress socketAddress, String channelId) {
        this.socketAddress = socketAddress;
        this.channelId = channelId;
    }

    public ChannelIdentity() {
    }

    public SocketAddress getSocketAddress() {
        return socketAddress;
    }

    public void setSocketAddress(SocketAddress socketAddress) {
        this.socketAddress = socketAddress;
    }

    public String getChannelId() {
        return channelId;
    }

    public void setChannelId(String channelId) {
        this.channelId = channelId;
    }

    public String getUserIdentity() {
        return userIdentity;
    }

    public void setUserIdentity(String userIdentity) {
        this.userIdentity = userIdentity;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ChannelIdentity that = (ChannelIdentity) o;
        return Objects.equals(socketAddress, that.socketAddress) && Objects.equals(channelId, that.channelId) && Objects.equals(userIdentity, that.userIdentity);
    }

    @Override
    public int hashCode() {
        return Objects.hash(socketAddress, channelId, userIdentity);
    }
}
